package com.hq.cms.utils;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAop {

    @Pointcut("execution(* com.hq.cms.service.*.*(..))")
    private void myPC(){

    }

    @Before("myPC()")
    public void before(){
        System.err.println("前置通知");
    }
    @Around("myPC()")
    public Object around(ProceedingJoinPoint  proceedingJoinPoint) throws Throwable {
        long l = System.currentTimeMillis();
        Object proceed = proceedingJoinPoint.proceed();
        long l1 = System.currentTimeMillis();
        System.out.println("耗时："+(l1-l));
        return proceed;
    }
}
